/*
 * Copyright (c) 2024 endless-sky
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _HAL_YUV_H_
#define _HAL_YUV_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "hal_struct.h"

/**
 * @function: Hal_Yuv_Create
 * @breif 创建YUV数据源
 *
 * @param[in]:  HAL_U8 u8SenIdx 视频输入通道号
 * @param[in]:  HAL_U32 height 图片高度
 * @param[in]:  HAL_U32 width  图片宽度
 * @param[in]:  HAL_U32 fps  帧率
 *
 * @return	 返回DSP_SUCCESS-成功，其它值		 失败，请参考错误码
 */
int32_t Hal_Yuv_Create(uint8_t u8SenIdx, uint8_t u8YuvIdx, HAL_YUV_PARAM_INIT_S *pParam);

/**
 * @function: Hal_Yuv_Destroy
 * @breif 销毁
 *
 * @param chId: 通道号
 * @return	返回DSP_SUCCESS-成功，其它值		失败，请参考错误码
 */
int32_t Hal_Yuv_Destroy(uint8_t u8SenIdx, uint8_t u8YuvIdx);

/**
 * @function:   Hal_Yuv_GetFrame
 *
 * @brief:      获取视频YUV数据，调用一次获取一帧
 * @param[in]:  HAL_U8 u8SenIdx 	视频输入通道号
 * @param[out]: QueYuvFrame_s *pFrame  YUV帧信息    帧信息为先保存Y数据，再保存UV数据，就是YUV帧
 *
 * @return  返回DSP_SUCCESS-成功，其它值        失败，请参考错误码
 */
int32_t Hal_Yuv_GetFrame(uint8_t u8SenIdx, uint8_t u8YuvIdx, HAL_YUV_FRAME_S *pFrame);

/**
 * @function:   Hal_Yuv_ReleaseFrame
 *
 * @brief:      获取视频YUV数据，调用释放之前获取的帧
 * @param[in]:  HAL_U8 u8SenIdx               视频输入通道号
 * @param[out]: release_handler 释放帧的句柄，从GetStream得到
 *
 * @return  返回DSP_SUCCESS-成功，其它值        失败，请参考错误码
 */
int32_t Hal_Yuv_ReleaseFrame(uint8_t u8SenIdx, uint8_t u8YuvIdx, HAL_YUV_FRAME_S *pFrame);

#ifdef __cplusplus
}
#endif

#endif // _HAL_YUV_H_
